var utils = require('../../../utils/util.js')
var c = require('../../../utils/config.js')
Page({
    data: {
        collectionList:[],
        img_url: c.img_url,
        page:1
    },
    onLoad: function (options) {
      this.getData()
    },
    //下拉刷新
    onPullDownRefresh: function () {
      this.setData({
        collectionList:[],
        page: 1,
      });
      this.getData();
    },
    //上拉加载
    onReachBottom: function () {
      this.getData();
    },
    onShow: function () {
        
    },
    getData:function(){
      var that = this;
      var token = wx.getStorageSync("userinfo").wap_token;
      var data = {
        url: "/v1/collect/lists",
        token: token,
        page: that.data.page,
        limit: 10,

      };
      utils.request(data).then(function (res) {
        if (res.code == 0) {
          var data = res.data;
          if (data.length > 0) {
            that.setData({
              page: that.data.page + 1
            });
          }
          that.setData({
            collectionList: that.data.collectionList.concat(data),
          });
        } else {

        }
        wx.stopPullDownRefresh();
      });
    },
    delCollection:function(e){
        var goods_id = 1;
        var that = this;
        var token = wx.getStorageSync("userinfo").wap_token;
        var data = {
            url: "/v1/collect/del",
            token: token,
            goods_id:goods_id
        };
        utils.request(data).then(function (res) {
            if (res.code == 0) {
                var data = res.data;
            } else {

            }
        });
    },
})